from queue import Queue
from threading import Thread


# Queue是先进先出
def producer(out_q):
    data = 100
    while data > 0:
        out_q.put(data)
        #print('放进去的数据是：', data)
        data -= 1


def consumer(in_q):
    while True:
        data = in_q.get()
        print('得到的数据是：', data)
        if data == 1:
            in_q.put(data)
            break


q = Queue()
t1 = Thread(target=producer, args=(q,))
t2 = Thread(target=consumer, args=(q,))
t1.start()
print(q.qsize())

